package com.agentworkflow.engine.core.model.node.event;

import com.agentworkflow.engine.core.enums.AppType;
import com.agentworkflow.engine.core.enums.DefaultNodeType;
import com.agentworkflow.engine.core.enums.NodeType;
import com.agentworkflow.engine.core.model.VariableConfig;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

@ToString(callSuper = true)
public class StartEvent extends EventNode {

    public static final String INPUT_VARIABLES = "input_variables";

    /**
     * 应用类型
     */
    @Getter
    private AppType appType = AppType.WORK_FLOW;

    /**
     * 触发器配置
     */
    @Getter
    private final TriggerConfig triggerConfig;

    @Override
    public NodeType getNodeType() {
        return DefaultNodeType.START_EVENT;
    }

    public StartEvent(String id, String name, String description, AppType appType, TriggerConfig triggerConfig, Map<String, VariableConfig> variables) {
        super(id, name, description);
        this.appType = appType;
        this.triggerConfig = triggerConfig;
        if (variables != null && !variables.isEmpty()) {
            setProperty(INPUT_VARIABLES, variables);
        } else {
            setProperty(INPUT_VARIABLES, new HashMap<String, VariableConfig>());
        }
    }
}
